<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
      <el-form-item label="片区" prop="deptId">
        <treeselect v-model="queryParams.deptId" style="width:200px;line-height:34px" size="medium" :options="zoneList" :show-count="true" placeholder="请选择片区" />
      </el-form-item>
      <el-form-item label="猪场名称" prop="pigfarmName">
        <el-input
          v-model="queryParams.pigfarmName"
          placeholder="请输入猪场名称"
          clearable
          size="medium"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建设类型" prop="buildType">
        <el-select v-model="queryParams.buildType" clearable placeholder="请选择" size="medium">
          <el-option label="楼房猪场" value="1"></el-option>
          <el-option label="平房猪场" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="list"  border size="mini" :height="listHeight || fillHeight('listHeight',['queryForm','add','pagination'],['hamburger-container','tags-view-container'], 130)">
      <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
      <el-table-column label="立项编码" prop="projectNumber" :show-overflow-tooltip="true" width="220" />
      <el-table-column label="立项名称" prop="projectName" :show-overflow-tooltip="true" width="150" align="center"/>
      <el-table-column label="进度%" prop="pigfarmProjectExt.progress" width="150" align="center"/>
      <el-table-column label="计划开始" prop="beginTime" width="150" align="center"/>
      <el-table-column label="计划结束" prop="endTime" width="150" align="center"/>
      <el-table-column label="实际开始" prop="pigfarmProjectExt.startDate" width="150" align="center"/>
      <el-table-column label="实际结束" prop="pigfarmProjectExt.endDate" width="150" align="center"/>

      <el-table-column label="竣工验收" align="center" width="100" >
        <template slot-scope="scope">
          <span v-if="scope.row.pigfarmProjectExt.completeCheck == '1'">完成</span>
          <span v-else>未完成</span>
        </template>
      </el-table-column>

      <el-table-column label="项目经理" prop="projectManagerName" align="center" width="150" />

      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="200" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleChange(scope.row.id,scope.row.projectName,scope.row.pigfarmInfo.pigfarmName)"
          >编制</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listForm,getTreeselect,delForm} from "@/api/progressManagement/constructionPlan";
import { roleOption } from "@/api/auth/role";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/auth/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import BaseIndex from '@/views/base/BaseIndex'
export default {
  name: "ConstructionPlan",
  components: { Treeselect },
  extends: BaseIndex,
  data() {
    return {
      listHeight:0,
      zoneList:[],
      props:{
        value:'id',
        label:'label'
      },
      loginOa:''
    };
  },
  watch: {

  },
  created() {
    this.loginOa = this.$store.state.user.account;
    console.log(this.ids)
    this.getList();

    getTreeselect().then(
      response => {
        if(response && response.code ===0){
          this.zoneList = response.data
        }else{
          this.msgError(response.msg)
        }
        this.loading = false;
      }
    );

  },
  methods: {
    listForm,
    delForm,
    handleChange(id,projectName,pigfarmName){  // 修改
      this.$router.push({path: "constructionPlanDetails", query: {
        type:'change',
        id,
        projectName,
        pigfarmName
      }});
    },
    handleSubCat(e){
      console.log(e[1])
      this.queryParams.deptId = e[1]
    },
    handleAddFn(){
      this.$router.push({path: "constructionPlanDetails", query: {
        type:'add'
      }});
    },
    handleDetails(id){
      this.$router.push({path: "constructionPlanDetails", query: {
        type:'details',
        id
      }});
    }
  }
};
</script>
